//# sourceURL=http://uMapApp/Earth/ViewPort
define([
    "mhjs/mhjs",
    "uMap/uMap",
    "uEarth/uEarth"
], function (
    mhjs,
    uMap,
    uEarth
) {

    function ViewPort(option) {

        var _this = this;

        if (!option || option.constructor.name !== "ViewPort") {

            _this.center = option && option.center || option.position;
            _this.hpr = option && option.hpr || option.orientation;

        } else {
            return option;
        }

    }

    var _class = ViewPort;

    Object.defineProperties(_class.prototype, {
        center        : {
            get: function () {
                return this._center;
            },
            set: function (value) {
                this._center = new uMap.Position(value);
            }
        },
        hpr           : {
            get: function () {
                return this._hpr;
            },
            set: function (value) {

                value = $.extend({}, {
                    "heading": 0,
                    "pitch"  : -45,
                    "range"  : 200
                }, value);

                this._hpr = new uEarth.HeadingPitchRange(
                    uEarth.Math.toRadians(value.heading),
                    uEarth.Math.toRadians(value.pitch),
                    value.range
                );
            }
        },
        boundingSphere: {
            get: function () {

                var _this = this;

                return new uEarth.BoundingSphere(
                    _this.center.cartesian,
                    _this.hpr.range
                );
            }
        }
    });

    mhjs.EventInterface(_class);

    return _class;

});